---
sidebar_label: Reset Migrations and Metadata
sidebar_position: 10
description: Reset Hasura Migrations and Metadata
keywords:
  - hasura
  - migration
  - metadata
  - restart
  - reset migrations
  - clear migrations
---

# Reset Hasura Migrations and Metadata

## Introduction

This page explains how to reset the state of Migrations and create new Migrations from the state that is on the
server. This can be useful if the current migration state on your local machine is corrupted.

## Step 1: Delete or backup the local migration files

Move all your Migrations to a backup folder, in case you need them later.

You can use the following bash move command to move the folder:

```bash
# move the contents of the migrations folder into the migrations_backup folder

mv migrations migrations_backup
```

## Step 2: Reset the migration history on the server

To reset the Migrations history status on the server only, use:

```bash
# reset migrations on server only

hasura migrate delete --all --server --database-name <database-name>
```

CLI will log:

```text
? clear all migrations of database and it's history on the server? (Y/n)
```

Enter `Y` to execute the command.

To reset the Migrations status on server and clean up the local project migration files

```bash
# reset migrations on server and on local project, use:

hasura migrate delete --all --database-name <database-name>
```

## Step 3: Pull the schema and Metadata from the server

If the Migrations were reset, then we will set up fresh Migrations by pulling the schema and Metadata from the
server using the following commands:

```bash
## create migration files - "this will only export public schema from postgres"

hasura migrate create "init" --from-server --database-name <database-name>
```

:::info When using a non-Postgres database

Please note that when using the `migrate create init --from-server` command, Hasura only supports Postgres databases.
Should you wish to use a different database, you will need to manually create the migration files. For more information,
please see this section of the [Migrations](/migrations-metadata-seeds/manage-migrations.mdx#create-manual-migrations)
documentation.

:::

```bash
## note down the version
## mark the migration as applied on this server

hasura migrate apply --version "<version>" --skip-execution --database-name <database-name>
```

```bash
## to also export the Hasura Metadata and save it in the ``/metadata`` directory

hasura metadata export
```

:::info Note

If you are using schemas other than `public`, use the `--schema <schema_name>` flag to indicate each one of them in
the create command. This flag can be used multiple times.

:::

## Step 4: Verify the status of the Migrations

Run the following command to verify the migration status:

```bash
hasura migrate status  --database-name <database-name>
```

You should see the new Migrations!
